package demo1;
/*
* 编写四方格父类
* 属性：Cell数组用于创建4个小方块
* 方法：移动、变形（暂时不写）
* */
public class Tetromino {
    protected Cell[] cells = new Cell[4];

    //编写左移方法
    public void moveLeft(){
        for (Cell cell : cells) {
            cell.left();
        }
    }
    //编写右移方法
    public void moveRight(){
        for (Cell cell : cells) {
            cell.right();
        }
    }
    //编写下落方法
    public void softDrop(){
        for (Cell cell : cells) {
            cell.drop();
        }
    }
    //编写随机生成四方格的方法
    public static Tetromino randomOne(){
        int num = (int)(Math.random()*7);
        Tetromino tetromino = null;
        switch (num){
            case 0:
                tetromino = new I();
                break;
            case 1:
                tetromino = new J();
                break;
            case 2:
                tetromino = new L();
                break;
            case 3:
                tetromino = new O();
                break;
            case 4:
                tetromino = new S();
                break;
            case 5:
                tetromino = new T();
                break;
            case 6:
                tetromino = new Z();
                break;
        }
        return tetromino;
    }
}
